Skip to content

Fix executeQuery default return type #1055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2023

Conversation

bigmontz
Copy link
Contributor

The executeQuery method was returning Promise<unknown> when no transformer or typing was provided like in the example bellow:

// works
const { records } = await driver.executeQuery<EegerResult>(`query`)

// works
const { records }: EagerResult = await driver.executeQuery(`query`)

// doesn't work, but it is fixed by this change
const { records } = await driver.executeQuery(`query`)

Defining a default generic type solves the issue.

The executeQuery method was returning `Promise<unknown` when no transformer or typing was provided like in the example bellow:

```
// works
const { records } = await driver.executeQuery<EegerResult>(`query`)

// works
const { records }: EagerResult = await driver.executeQuery(`query`)

// doesn't work, but it is fixed by this change
const { records } = await driver.executeQuery(`query`)
```

Defining a default generic type solves the issue.
Copy link
Member

@robsdedude robsdedude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well typed

Copy link
Contributor

@fbiville fbiville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eager to see this merged 🥁

@@ -342,6 +342,32 @@ describe('Driver', () => {
}, query, params)
})

it('should be able to destruct the result in records, keys and summary', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should be able to destruct the result in records, keys and summary', async () => {
it('should be able to destructure the result in records, keys and summary', async () => {

@bigmontz bigmontz merged commit 15386b7 into neo4j:5.0 Jan 31, 2023
@bigmontz bigmontz deleted the 5.x-fix-generic-default branch January 31, 2023 15:08
bigmontz added a commit to bigmontz/neo4j-javascript-driver that referenced this pull request Mar 6, 2023
The executeQuery method was returning `Promise<unknown` when no transformer or typing was provided like in the example bellow:

```
// works
const { records } = await driver.executeQuery<EegerResult>(`query`)

// works
const { records }: EagerResult = await driver.executeQuery(`query`)

// doesn't work, but it is fixed by this change
const { records } = await driver.executeQuery(`query`)
```

Defining a default generic type solves the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants